unit FPrincipal;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Vcl.ComCtrls;

type
  TForm1 = class(TForm)
    edtStrOrig: TEdit;
    edtStrInv: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    btnTeste: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure FormShow(Sender: TObject);
    procedure edtStrOrigChange(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure btnTesteClick(Sender: TObject);
  private
    { Private declarations }
    function InverteString(str : String):String;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  edtStrOrig.Clear;
  edtStrInv.Clear;
  edtStrOrig.SetFocus;
end;

procedure TForm1.btnTesteClick(Sender: TObject);
begin
  ShowMessage('Teste');
end;

procedure TForm1.edtStrOrigChange(Sender: TObject);
begin
  edtStrInv.Text := InverteString(edtStrOrig.Text);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  edtStrOrig.Clear;
  edtStrInv.Clear;
  edtStrOrig.SetFocus;
end;

function TForm1.InverteString(str: String): String;
var aux : String;
    I: Integer;
begin
  Result := '';
  aux := '';

  if str <> '' then
   begin
      for I := Length(str) downto 0 do
        begin
          aux := aux + str[I];
        end;
   end;

  Result := aux;
end;

end.
